﻿using System;
using System.Data.Entity;
using System.Text;
using Model.Core.DataBase.EntityFramework;

namespace Model.Core.DataBase {
    /// <summary>
    ///     数据库配置管理
    ///     By Dongyan
    ///     Creation Time: [ 2013/2/26 19:09:35 ]
    ///     Email: yan.dycn@gmail.com
    /// </summary>
    public class DbContextFactory {
        /// <summary>
        ///     根据连接字符串,创建一个数据库容器
        /// </summary>
        /// <param name="containerType">数据容器类型</param>
        /// <param name="dbConnectName">连接字符串名称</param>
        /// <returns>数据库上下文接口实现</returns>
        public static IDbContext CreateEntityFrameworkContext(Type containerType, string dbConnectName) {
            var containerObj = (BaseContainer)Activator.CreateInstance(containerType, dbConnectName);
            return new DbContextkAdapter(containerObj);
        }

    }

}